package com.daify.threadlearn.chapter01.order03;

/**
 * @author daify
 * @date 2019-06-05
 */
public class Counter {

    private long value = 0;

    public synchronized long getValue() {
        return value;
    }

    public synchronized long increment() {
        if (value == Long.MAX_VALUE) {
            throw new IllegalStateException("overflow");
        }
        return ++value;
    }

}
